<!--
  Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

  https://www.mall4j.com/

  未经允许，不可做商业用途！

  版权所有，侵权必究！
-->

<template>
  <div class="Mall4j page-submit-order">
    <div class="content">
      <div class="step-box">
        <div class="left">
          <span class="img" />
          <span class="text">{{ $t('submitOrder.submitOrder') }}</span>
        </div>
        <div class="steps">
          <div class="item">
            <div class="number">
              step 01.
            </div>
            <div class="text">
              {{ $t('submitOrder.selectProductToBuy') }}
            </div>
          </div>
          <div class="item active">
            <div class="number">
              step 02.
            </div>
            <div class="text">
              {{ $t('submitOrder.confirmOrderInformation') }}
            </div>
          </div>
          <div class="item">
            <div class="number">
              step 03.
            </div>
            <div class="text">
              {{ $t('submitOrder.payToCompleteTheOrder') }}
            </div>
          </div>
        </div>
      </div>
      <div class="submit-con">
        <!-- 收货地址 -->
        <div
          v-if="orderInfo.mold !== 1"
          class="submit-box"
        >
          <div class="tit">
            <span class="text">{{ $t('address.receivingAddress') }}</span>
            <!-- <span class="action">显示全部地址</span> -->
          </div>
          <div class="con address-box">
            <div
              v-for="address in addressList"
              :key="address.addrId"
              :class="['item', address.commonAddr?'default-address':'',selectedAddrId===address.addrId?'active':'']"
              @click="changeAddress(address.addrId)"
            >
              <div class="name-phone">
                <span class="name">{{ address.receiver }}</span>
                <span class="phone">{{ address.mobile }}</span>
                <span
                  v-if="!address.commonAddr"
                  class="set-default"
                  @click="setDefaultAddr(address.addrId)"
                >{{ $t('address.setDefault') }}</span>
                <span
                  v-if="address.commonAddr"
                  class="default-tag"
                >{{ $t('address.default') }}</span>
              </div>
              <div
                class="address-detail"
              >
                {{ address.province+address.city+address.area+address.addr }}
              </div>
              <div class="del-edit">
                <span
                  class="edit"
                  @click.stop="editAddr(address.addrId)"
                />
                <span
                  class="del"
                  @click.stop="toggleDelAddr(true,address.addrId)"
                />
              </div>
            </div>
            <div
              v-if="addressList.length < 10"
              class="item add-address"
              @click="toggleAddrPop(true)"
            >
              <div class="add-box">
                <div class="img">
                  +
                </div>
                <div class="text">
                  {{ $t('address.addAddress') }}
                </div>
              </div>
            </div>
          </div>
          <div
            v-if="showDelAddr"
            class="popup-mask"
          />
          <div class="fix-transform-blur">
            <div
              v-if="showDelAddr"
              class="popup-box"
            >
              <div
                class="tit"
                style="padding:10px;"
              >
                <div class="text">
                  {{ $t('tips') }}
                </div>
                <div
                  class="close"
                  @click="toggleDelAddr(false)"
                />
              </div>
              <div class="con">
                <div class="tip">
                  <div class="tip-icon warning" />
                  <div class="tip-info">
                    <div class="result">
                      {{ $t('address.deleteShippingAddress') }}
                    </div>
                    <div class="date">
                      {{ $t('address.deleteShippingTips') }}
                    </div>
                    <div class="btns">
                      <a
                        href="javascript:void(0);"
                        class="btn-r"
                        @click="delAddr()"
                      >{{ $t('delete') }}</a>
                      <a
                        href="javascript:void(0);"
                        class="btn-g"
                        @click="toggleDelAddr(flase)"
                      >{{ $t('cancel') }}</a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- 收货地址 -->
        <!-- 支付方式 -->
        <div class="submit-box">
          <div class="tit">
            <span class="text">{{ $t('commonFoot.paymentMethod') }}</span>
          </div>
          <div class="con pay-way">
            <div class="item active">
              {{ $t('submitOrder.payOnline') }}
            </div>
            <!-- <div class="item">货到付款</div>
            <div class="item">线下支付</div>-->
          </div>
        </div>
        <!-- 支付方式 -->
        <!-- 配送方式 -->
        <div
          v-if="orderInfo.mold !== 1"
          class="submit-box"
        >
          <div class="tit">
            <span class="text">{{ $t('submitOrder.deliveryMethod') }}</span>
          </div>
          <div class="con delivery-way">
            <div class="item active">
              {{ $t('submitOrder.courierDelivery') }}
            </div>
            <!-- <div class="item">到店自提</div> -->
            <!-- <div class="description">（该商品不支持自提）</div> -->
          </div>
        </div>
        <!-- /配送方式 -->
        <!-- 商品信息 -->
        <div class="submit-box goods-info">
          <div class="tit">
            <span class="text">{{ $t('applyReturn.productInformation') }}</span>
          </div>
          <div class="goods-msg">
            <div class="msg-tab">
              <div class="img">
&nbsp;
              </div>
              <div class="info">
                {{ $t('products') }}
              </div>
              <div class="unit-price">
                {{ $t('prodDetail.originalPrice') }}
              </div>
              <div class="unit-price">
                {{ $t('prodDetail.shaJia') }}
              </div>
              <div class="freight">
                {{ $t('submitOrder.shippingFee') }}
              </div>
              <div class="number">
                {{ $t('quantity') }}
              </div>
              <div class="total">
                {{ $t('subtotal') }}
              </div>
            </div>
            <div class="msg-con">
              <!-- 店铺 -->
              <div class="shop-msg">
                <router-link
                  :to="'/shop-index?sid=' + shopCartItem.shopId"
                  class="shop-name"
                >
                  {{ $t('index.shop') }}：{{ shopCartItem.shopName }}
                </router-link>
                <span
                  v-if="shopCartItem.shopId === 1"
                  class="self"
                >{{ $t('prodDetail.selfEmployed') }}</span>
              </div>
              <!-- 店铺中的商品 -->

              <div class="goods-box">
                <div class="prod-row">
                  <div class="img">
                    <div
                      class="img-box"
                      @click="toProdDetail(shopCartItem.prodId)"
                    >
                      <ImgShow :src="shopCartItem.pic" />
                    </div>
                    <div
                      v-if="!(shopCartItem.isDelivery)"
                      class="no-delivery"
                    >
                      不支持配送
                    </div>
                  </div>
                  <div class="info">
                    <div
                      class="name"
                      @click="toProdDetail(shopCartItem.prodId)"
                    >
                      {{ shopCartItem.prodName }}
                    </div>
                    <span class="sku">{{ shopCartItem.skuName }}</span>
                  </div>
                  <div
                    class="unit-price"
                  >
                    ￥{{ parsePrice(shopCartItem.productTotalAmount/shopCartItem.prodCount)[0] }}.{{ parsePrice(shopCartItem.productTotalAmount/shopCartItem.prodCount)[1] }}
                  </div>
                  <div
                    class="unit-price"
                  >
                    ￥{{ parsePrice(shopCartItem.price)[0] }}.{{ parsePrice(shopCartItem.price)[1] }}
                  </div>
                  <div
                    class="freight"
                  >
                    ￥{{ parsePrice(orderInfo.totalTransFee)[0] }}.{{ parsePrice(orderInfo.totalTransFee)[1] }}
                  </div>
                  <div class="number">
                    {{ shopCartItem.prodCount }}
                  </div>
                  <div
                    v-if="shopCartItem.isDelivery"
                    class="total"
                  >
                    ￥{{ parsePrice(shopCartItem.productTotalAmount)[0] }}.{{ parsePrice(shopCartItem.productTotalAmount)[1] }}
                  </div>
                  <div
                    v-else
                    class="total"
                  >
                    ￥0
                  </div>
                </div>
                <!-- 虚拟商品留言 start -->
                <div
                  v-if="orderInfo.virtualRemarkList && orderInfo.virtualRemarkList.length"
                  class="virtual-goods-msg"
                >
                  <div :class="['msg-tit',$t('language')==='en' ? 'msg-tit-en' : '']">
                    <span class="text">{{ $t('submitOrder.userMessage') }}：</span>
                  </div>
                  <div>
                    <div
                      v-for="(msgItem,msgIndex) in orderInfo.virtualRemarkList"
                      :key="msgIndex"
                      class="msg-item"
                    >
                      <span
                        v-if="msgItem.isRequired"
                        class="red-stress"
                      >*</span>
                      <input
                        v-model="msgItem.value"
                        class="msg-int-item"
                        type="text"
                        :placeholder="$t('submitOrder.pleaseEnter') + `${msgItem.name}`"
                        maxlength="20"
                        @blur="handleInputBlur(msgItem.value, msgIndex)"
                      >
                    </div>
                  </div>
                </div>
                <!-- 虚拟商品留言 end -->
              </div>

              <div
                v-if="shopCartItem.isDelivery"
                class="remake-box"
              >
                {{ $t('submitOrder.messageToMerchant') }}：
                <input
                  v-model="remarks"
                  type="text"
                  maxlength="100"
                  class="text"
                  :placeholder="$t('submitOrder.numberLength100')"
                >
                <!-- 发票 -->
                <div class="invoice-title">
                  {{ $t('invoice.invoiceInfo') }}
                </div>
                <div
                  v-if="shopCartItem.invoiceDataFrom"
                  class="invoice-box"
                >
                  <div
                    v-if="shopCartItem.invoiceDataFrom.invoiceType === 1"
                    class="invoice-box-item invoice-type"
                  >
                    {{ $t('invoice.generalInvoice') }}
                  </div>
                  <div
                    v-if="shopCartItem.invoiceDataFrom.invoiceType === 2 || !shopCartItem.invoiceDataFrom"
                    class="invoice-box-item invoice-type"
                  >
                    {{ $t('invoice.noInvoice') }}
                  </div>
                  <div
                    v-if="shopCartItem.invoiceDataFrom.invoiceType === 1"
                    class="invoice-box-item invoice-unit"
                  >
                    {{ shopCartItem.invoiceDataFrom.headerName || $t('invoice.personal') }}
                  </div>
                  <div
                    v-if="shopCartItem.invoiceDataFrom.invoiceType === 1"
                    class="invoice-box-item invoice-contents"
                  >
                    {{ $t('invoice.productDetails') }}
                  </div>
                  <div
                    class="invoice-box-item invoice-operation"
                    @click="showAddOrUpdateDialog(0,shopCartItem,shopCartItem.shopId)"
                  >
                    {{ $t('invoice.update') }}
                  </div>
                </div>
                <div
                  v-else
                  class="invoice-box"
                >
                  <div class="invoice-box-item invoice-type">
                    {{ $t('invoice.noInvoice') }}
                  </div>
                  <div
                    class="invoice-box-item invoice-operation"
                    @click="showAddOrUpdateDialog(0,shopCartItem,shopCartItem.shopId)"
                  >
                    {{ $t('invoice.update') }}
                  </div>
                </div>
                <!-- 发票 -->
              </div>
              <!-- /留言 -->
            </div>
          </div>
        </div>
      </div>
      <div class="submit-bottom">
        <div
          v-if="orderInfo.totalCount"
          class="statistic-box"
        >
          <div class="item">
            <div class="tit">
              <span class="number">{{ orderInfo.totalCount }}</span>{{ $t('submitOrder.totalItems') }}：
            </div>
            <div class="con">
              ￥{{ parsePrice(orderInfo.total)[0] }}.{{ parsePrice(orderInfo.total)[1] }}
            </div>
          </div>
          <!-- 应付运费 -->
          <div
            v-if="orderInfo.mold !== 1"
            class="item"
          >
            <div class="tit">
              {{ $t('submitOrder.freightPayable') }}：
            </div>
            <div
              class="con"
            >
              ￥{{ parsePrice(orderInfo.totalTransFee)[0] }}.{{ parsePrice(orderInfo.totalTransFee)[1] }}
            </div>
          </div>
          <!-- 平台开启会员包邮(运费减免) -->
          <div
            v-if="orderInfo.freeTransFee"
            class="item"
          >
            <div class="tit">
              {{ $t('submitOrder.memberPackage') }}：
            </div>
            <div class="con bright">
              <p>
                -￥{{ parsePrice(orderInfo.freeTransFee)[0] }}.{{
                  parsePrice(orderInfo.freeTransFee)[1]
                }}
              </p>
            </div>
          </div>
          <!-- 秒杀优惠 -->
          <div
            v-if="orderInfo.orderReduce > 0"
            class="item"
          >
            <div class="tit">
              {{ $t('submitOrder.seckillReduce') }}：
            </div>
            <div
              class="con bright"
            >
              -￥{{ parsePrice(discountAmount)[0] }}.{{ parsePrice(discountAmount)[1] }}
            </div>
          </div>
        </div>

        <div class="detail-box">
          <div class="item">
            <div class="tit">
              {{ $t('submitOrder.totalPayable') }}：
            </div>
            <div
              class="con"
            >
              ￥{{ parsePrice(orderInfo.actualTotal)[0] }}.{{ parsePrice(orderInfo.actualTotal)[1] }}
            </div>
          </div>
          <div
            v-if="currentAddr.addrId"
            class="item"
          >
            <span
              class="text"
            >{{ $t('submitOrder.sendTo') }}：{{ currentAddr.province+' '+currentAddr.city +' '+currentAddr.area+' '+currentAddr.addr }}</span>
            <span class="text">{{ $t('submitOrder.consignee') }}：{{ currentAddr.receiver }} {{ currentAddr.mobile }}</span>
          </div>
        </div>
        <div class="btn-box">
          <a
            v-if="shopCartItem.isDelivery"
            href="javascript:void(0)"
            class="btn"
            @click="submitOrder"
          >{{ $t('submitOrder.submitOrder') }}</a>
          <a
            v-else
            href="javascript:void(0)"
            class="disable-btn"
          >{{ $t('submitOrder.submitOrder') }}</a>
        </div>
      </div>
    </div>
    <!-- 地址弹窗 -->
    <AddressPop
      v-if="showAddrPop"
      :edit-addr-id="editAddrId"
      @get-addr-list="getAddrList"
      @toggle-addr-pop="toggleAddrPop"
    />
    <!-- /地址弹窗 -->
    <!-- 发票弹窗 -->
    <addOrEditInvoice
      v-if="showInvoiceAdd"
      ref="invoiceAddOrUpdateRef"
      @toggle-addr-pop="refreshChange"
      @get-invoice-data="getInvoiceData"
      @hide-pop="hideInvoicePop"
    />
    <confirm-popup
      v-if="dialogVisible"
      :pop-configuration="deliveryConfig"
      @cancel="dialogVisible = false"
      @confirm="$router.go('-1')"
    />
  </div>
</template>

<script setup>
import Cookie from 'vue-cookies'
import { bus } from '@/utils/bus'
import AddressPop from '@/components/add-or-edit-address/index.vue'
import addOrEditInvoice from '@/components/add-or-edit-invoice/index.vue'
import confirmPopup from '@/components/confirm-popup/index.vue'
import Big from 'big.js'
import { ElMessage, ElLoading } from 'element-plus'

// 发票弹窗
const showInvoiceAdd = ref(false)
let dialogVisible = ref(false)
const deliveryConfig = {
  title: '提示',
  firstLineText: '',
  confirmText: '确认',
  cancelText: '取消'
}
const orderInfo = ref({})
const discountAmount = computed(() => {
  return parseFloat(new Big(orderInfo.value.orderReduce || 0).minus(orderInfo.value.shopFreeTransFee || 0).minus(orderInfo.value.freeTransFee || 0))
})
let secKillObj = {} // 秒杀订单数据
onMounted(() => {
  getAddrList()
  secKillObj = JSON.parse(sessionStorage.getItem('bbcSecKillObj'))
  getSecOrderPath()
})

/**
 * 跳转商品详情
 */
const router = useRouter()
const toProdDetail = (prodId) => {
  http.get('/p/seckill/prod', {
    params: {
      prodId
    }
  }).then(() => {
    const newPage = router.resolve({ path: '/detail', query: { prodId } })
    window.open(newPage.href, '_blank', 'noopener,noreferrer')
  })
}
const invoiceAddOrUpdateRef = ref(null)
const showAddOrUpdateDialog = (st, shopCartItem, shopId) => {
  showInvoiceAdd.value = true
  const param = shopCartItem.invoiceDataFrom ? shopCartItem.invoiceDataFrom : ''
  nextTick(() => {
    invoiceAddOrUpdateRef.value?.init(st, param, '', shopId)
  })
}
/**
 * 刷新回调
 */
const refreshChange = (visible) => {
  showInvoiceAdd.value = visible
}
/**
 * 发票信息
 */
const shopCartItem = ref({})
const getInvoiceData = (invoiceDataFrom) => {
  if (invoiceDataFrom.headerType === 2) {
    delete invoiceDataFrom.invoiceTaxNumber
  }
  if (shopCartItem.value.shopId === invoiceDataFrom.shopId) {
    shopCartItem.value.invoiceDataFrom = invoiceDataFrom
  }
  showInvoiceAdd.value = false
}
const hideInvoicePop = (visible) => {
  showInvoiceAdd.value = visible
}
/**
 * 获取地址列表
 */
let orderPath = '' // 秒杀订单路径
const selectedAddrId = ref(0)
const getAddrList = () => {
  http.get('/p/address/list').then(({ data }) => {
    addressList.value = data
  })
  if (orderPath && (selectedAddrId.value || selectedAddrId.value === 0)) {
    confirmSecOrder(orderPath)
  }
}

/**
 * 选择地址
 */
const currentAddr = ref({}) // 当前选择的地址
const addressList = ref([])
const changeAddress = (addrId) => {
  addressList.value.forEach(element => {
    if (element.addrId === addrId) {
      currentAddr.value = element
    }
  })
  selectedAddrId.value = addrId
  confirmSecOrder(orderPath)
}

/**
 * 设置为默认地址
 */
const setDefaultAddr = (addrId) => {
  http.put('/p/address/defaultAddr/' + addrId).then(({ data }) => {
    ElMessage({
      message: data,
      type: 'success',
      duration: 1000
    })
    getAddrList()
  })
}
/**
 * 显示/隐藏确认删除弹窗
 */
const showDelAddr = ref(false)
const editAddrId = ref(0) // 要修改的地址id
const toggleDelAddr = (sts, addrId) => {
  showDelAddr.value = sts
  editAddrId.value = addrId
}
/**
 * 显示/隐藏地址弹窗
 */
const showAddrPop = ref(false) // 地址弹窗显隐
const toggleAddrPop = (sts) => {
  if (Cookie.get('bbcToken')) {
    showAddrPop.value = sts
    editAddrId.value = 0
  } else {
    bus.$emit('showLogin', true)
    showAddrPop.value = false
  }
}

/**
 * 修改地址 (弹窗传地址id)
 */
const editAddr = (addrId) => {
  if (Cookie.get('bbcToken')) {
    showAddrPop.value = true
    editAddrId.value = addrId
  } else {
    bus.$emit('showLogin', true)
    showAddrPop.value = false
  }
}
/**
 * 删除地址
 */
const delAddr = () => {
  if (editAddrId.value === selectedAddrId.value) {
    secKillObj.addrId = 0
    selectedAddrId.value = 0
  }
  http.delete('/p/address/deleteAddr/' + editAddrId.value).then(({ data }) => {
    ElMessage({
      message: data,
      type: 'success',
      duration: 1000
    })
    toggleDelAddr(false)
    getAddrList()
  })
}
/**
 * 价格处理
 */
const parsePrice = (value) => {
  let val = Number(value)
  if (!val) {
    val = 0
  }
  // 截取小数点后两位，并以小数点为切割点将val转化为数组
  return val.toFixed(2).split('.')
}
/**
 * 获取 orderPath
 */
const getSecOrderPath = () => {
  const that = this
  http.get('/p/seckill/orderPath?prodId=' + secKillObj.prodId).then(({ data }) => {
    orderPath = data
    confirmSecOrder(data)
  }).catch(({ data }) => {
    if (data.code === 'A00001') {
      setTimeout(() => {
        that.$router.go(-1)
      }, 1500)
    }
  })
}

/**
 * 确认秒杀订单
 */
let seckillOrderNumber = ''
const confirmSecOrder = (orderPath) => {
  const confirmParam = {
    addrId: selectedAddrId.value,
    orderItem: secKillObj,
    seckillSkuId: secKillObj.seckillSkuId,
    dvyType: 1
  }
  http.post(`/p/seckill/${orderPath}/confirm`, confirmParam).then(({ data }) => {
    orderInfo.value = data
    if (data.shopCartOrders && data.shopCartOrders.length > 0) {
      shopCartItem.value = data.shopCartOrders[0].shopCartItemDiscounts[0].shopCartItems[0]
    } else if (data.filterShopItems) {
      shopCartItem.value = data.filterShopItems[0]
    }
    if (data.userAddr) {
      currentAddr.value = data.userAddr
      selectedAddrId.value = data.userAddr.addrId
    }
  })
}

/**
 * 留言输入框失焦
 */
const handleInputBlur = (value, index) => {
  if (!value) {
    return
  }
  if (!value.trim()) {
    orderInfo.value.virtualRemarkList[index].value = value.trim()
  }
}

/**
 * 提交订单
 */
const remarks = ref('')
let loading = {}
const submitOrder = () => {
  if (orderInfo.value.mold !== 1 && !addressList.value.length) {
    ElMessage({
      message: $t('submitOrder.pleaseAddTheAddressFirst'),
      type: 'warning',
      duration: 1000
    })
    showAddrPop.value = true
    return
  }
  if (orderInfo.value.mold !== 1 && selectedAddrId.value === 0) {
    ElMessage({
      message: $t('submitOrder.pleaseAddTheAddressFirst'),
      type: 'warning',
      duration: 1000
    })
    document.body.scrollTop = document.documentElement.scrollTop = 0
    return
  }
  // 虚拟商品留言必填项校验
  if (
    orderInfo.value.mold === 1 &&
    orderInfo.value.virtualRemarkList.length &&
    orderInfo.value.virtualRemarkList.find(el => el.isRequired && !el.value)
  ) {
    ElMessage({
      message: $t('submitOrder.messageCannotBeEmpty'),
      type: 'warning',
      duration: 2500
    })
    return
  }
  // 显示秒杀loading
  seckillLoading()
  // 提交秒杀订单
  const orderShopParam = [{
    remarks: remarks.value,
    shopId: shopCartItem.value.shopId
  }]

  let orderInvoiceDTO = null // invoiceDataFrom
  if (shopCartItem.value.invoiceDataFrom && shopCartItem.value.invoiceDataFrom.invoiceType === 1) {
    orderInvoiceDTO = [shopCartItem.value.invoiceDataFrom]
  }
  // 处理埋点参数
  const orderFlowLogParam = JSON.parse(localStorage.getItem('bbcFlowAnalysisLogDto'))
  let step = localStorage.getItem('bbcStep') * 1
  step += 1
  orderFlowLogParam.visitType = 1
  orderFlowLogParam.step = step
  http.post(`/p/seckill/${orderPath}/submit`, {
    orderShopParams: orderShopParam,
    orderInvoiceList: orderInvoiceDTO,
    virtualRemarkList: orderInfo.value.virtualRemarkList,
    orderFlowLogParam
  }).then(({ data }) => {
    // 请求成功后，更新缓存
    localStorage.setItem('bbcStep', step)
    localStorage.setItem('bbcFlowAnalysisLogDto', JSON.stringify(orderFlowLogParam))
    localStorage.setItem('bbcSessionTimeStamp', new Date().getTime()) // 更新会话时间

    seckillOrderNumber = data.orderNumbers
    // 轮询秒杀订单提交状态
    setTimeout(checkSeckillOrderSubmitStatus, 3000)
  }).catch(({ data }) => {
    // 关闭秒杀loading
    loading.close()
    if (data.code === 'A07001') {
      orderInfo.value.shopCartOrders.forEach((shopCart) => {
        shopCart.shopCartItemDiscounts.forEach((shopCartItemDiscount) => {
          shopCartItemDiscount.shopCartItems.forEach((prodItem) => {
            if (!prodItem.isDelivery) {
              data.msg += prodItem.prodName + '、'
            }
          })
        })
      })
      data.msg = data.msg.substring(0, data.msg.length - 1)
      deliveryConfig.firstLineText = data.msg
      dialogVisible = true
    } else {
      router.go(-1)
    }
  })
}

/**
 *  轮询秒杀订单提交状态
 */
let pollingTimes = 0
let seckillOrderStsTimer = ''
const checkSeckillOrderSubmitStatus = () => {
  if (pollingTimes < 10) {
    http.get('/p/seckill/createOrderStatus', {
      params: {
        orderNumber: seckillOrderNumber
      }
    }).then(({ data }) => {
      if (data) {
        clearTimeout(seckillOrderStsTimer)
        loading.close()
        sessionStorage.setItem('bbcPay_total', shopCartItem.value.actualTotal)
        sessionStorage.setItem('bbcPay_orderNumber', seckillOrderNumber)
        sessionStorage.setItem('bbcPay_mold', orderInfo.value.mold)
        router.push({
          path: '/payment'
        })
      } else {
        pollingTimes++
        seckillOrderStsTimer = setTimeout(checkSeckillOrderSubmitStatus, 3000)
      }
    })
  } else {
    loading.close()
    ElMessage.warning($t('submitOrder.secFailTips'))
  }
}

/**
 * 秒杀loading
 */
const seckillLoading = () => {
  const loaded = ElLoading.service({
    lock: true,
    text: $t('submitOrder.inTheMadRushToBuy'),
    background: 'rgba(255, 255, 255, 0.8)'
  })
  loading = loaded
}

</script>

<style  lang="scss" scoped>
@use '../submit-order/index.scss';

.page-submit-order  {
  .submit-box{
    border-bottom: 1px solid #eee !important;
  }
  .fix-transform-blur {
    z-index: 10000;
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -40%);
}
  .prod-row .info{
    width: 420px !important;
  }
}

</style>
